package com.xhj.controller;

import com.xhj.entity.Banner;
import com.xhj.service.BannerService;
import com.xhj.util.ResultEntity;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 首页banner表(CrmBanner)表控制层
 *
 * @author makejava
 * @since 2021-03-05 15:49:04
 */
@RestController
@RequestMapping("/banner/")
@CrossOrigin
public class BannerController {

    @Autowired
    private BannerService bannerService;

    @ApiOperation(value = "获取全部图片")
    @RequestMapping("list")
    public ResultEntity getList(){
        List<Banner> bannerList = bannerService.list(null);
        if (bannerList == null || bannerList.size() == 0) throw new RuntimeException("数据库没有图片！");
        return ResultEntity.successWithData().data("list",bannerList);
    }

}